Easy2Siksha.com
Advantages of for Loop
• Reduces repetition of code.
• Makes programs shorter and easier to understand.
• Saves time and effort.
• Helps process lists, strings, tuples, and other collections efficiently.
• Improves code readability and maintenance.
Conclusion
Python data types define the kind of information stored in variables, such as numbers, text,
lists, sets, dictionaries, and Boolean values. Choosing the correct data type makes programs
accurate, efficient, and easier to manage.
The for control structure is one of the most useful looping mechanisms in Python. It
automatically repeats a block of code for each item in a sequence or over a range of values,
eliminating the need to write repetitive code. Together, data types and the for loop form
the foundation of Python programming and are essential concepts for writing clear,
efficient, and reliable programs.
4.(a) Write a program in Python to find count of odd numbers from a list of numbers.
(b) How break and continue statements are used by Python programs? Illustrate.
Ans: 4(a) Write a program in Python to find the count of odd numbers from a list of
numbers.
(b) How are break and continue statements used in Python programs? Illustrate.**
This question tests three important Python concepts:
1. Lists
2. Odd numbers and counting them
3. The break and continue statements
Let's understand each topic in the simplest way.
Part (a): Program to Count Odd Numbers in a List
Imagine you are a teacher checking the roll numbers of students.
Suppose the roll numbers are: